<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>

        // static  给构造函数添加私有属性或者方法   ---- 实例化对象不能访问

        class Dog {
            static type = '狗子';
            static fn() {
                console.log(1)
            }
            constructor() { }
        }

        const d = new Dog();
        console.log(Dog.type)

        Dog.fn()

        // d.fn()   // 报错

    </script>

</body>

</html>